﻿using System;
using System.Globalization;

namespace ICSharpCode.SharpZipLib.Compat
{
	/// <summary>
	/// Extensions class.
	/// </summary>
	public static class Extensions
	{
		/// <summary>
		/// Compare extenstion method for strings.
		/// </summary>
		/// <param name="left">Left string.</param>
		/// <param name="right">Right string.</param>
		/// <param name="ignoreCase">Ignores the case of the strings.</param>
		/// <param name="info">Cannot be null.</param>
		/// <returns></returns>
		public static int Compare(this string left, string right, bool ignoreCase, CultureInfo info)
		{
			if (info == null)
			{
				throw new ArgumentNullException("CultureInfo cannot be null!");
			}
			return ignoreCase
								 ? info.CompareInfo.Compare(left, right, CompareOptions.IgnoreCase)
								 : info.CompareInfo.Compare(left, right, CompareOptions.None);
		}
	}
}